<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" media="screen" href="../../css/bootstrap.min.css">
</head>
<body>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
	<form class="form-horizontal" onsubmit="return false" id="form">
		<fieldset>
			<input type="hidden" id="id" name="id">
			<div class='form-group'>
				<label class='col-md-2 control-label'>内部商品编号</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='itemNo' type='text' name='itemNo' id='itemNo' data-bv-notempty='true' data-bv-notempty-message='内部商品编号 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>sku库存编号/label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='sku' type='text' name='sku' id='sku' data-bv-notempty='true' data-bv-notempty-message='sku库存编号 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>商品名称</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='goodsName' type='text' name='goodsName' id='goodsName' data-bv-notempty='true' data-bv-notempty-message='商品名称 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>商品品类</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='goodsType' type='text' name='goodsType' id='goodsType' data-bv-notempty='true' data-bv-notempty-message='商品品类 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>商品品牌</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='brand' type='text' name='brand' id='brand' data-bv-notempty='true' data-bv-notempty-message='商品品牌 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>商品规格</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='specific' type='text' name='specific' id='specific' data-bv-notempty='true' data-bv-notempty-message='商品规格 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>商品产地</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='place' type='text' name='place' id='place' data-bv-notempty='true' data-bv-notempty-message='商品产地 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>商品特征</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='property' type='text' name='property' id='property' data-bv-notempty='true' data-bv-notempty-message='商品特征 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>预计商品采购成本价</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='preBuyCost' type='text' name='preBuyCost' id='preBuyCost' data-bv-notempty='true' data-bv-notempty-message='预计商品采购成本价 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>销售价格</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='price' type='text' name='price' id='price' data-bv-notempty='true' data-bv-notempty-message='销售价 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>销售单位</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='unit' type='text' name='unit' id='unit' data-bv-notempty='true' data-bv-notempty-message='销售单位 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>是否销售中</label>
				<div class='col-md-10'>
				    
					<input class='form-control' placeholder='isSale' type='radio' name='isSale'   data-bv-notempty='true' value=1> 销售中
					<input class='form-control' placeholder='isSale' type='radio' name='isSale'  data-bv-notempty='true' value=0> 不销售
				</div>
			</div>



			<div class="form-actions">
				<div class="row" align="center">
					<div class="col-md-12">
					    <button class="btn btn-primary" onclick="location.href='pGoodsList.html'">返回</button>
						<button class="btn btn-primary" type="submit" onclick="update()">
							<i class="fa fa-save"></i> 保存
						</button>
					</div>
				</div>
			</div>

		</fieldset>
	</form>
</div>
	<script type="text/javascript" src="../../js/libs/jquery-2.1.1.min.js"></script>
	<script type="text/javascript" src="../../js/jq.js"></script>
	<script type="text/javascript" src="../../js/plugin/bootstrapvalidator/bootstrapValidator.min.js"></script>
	<script type="text/javascript" src="../../js/common.js"></script>
	<script type="text/javascript" src="../../layui/layui.js"></script>
	<script type="text/javascript">
		layui.use(['layer','laydate'], function(){
		    var layer = layui.layer;
		});
		
		initData();
		
		function initData(){
			var id = getUrlParam("id");
			if(id != ""){
				$.ajax({
					type : 'get',
					url : '/pGoodss/'+id,
					async : false,
					success : function(data) {
						$('#id').val(data.id);
						$('#itemNo').val(data.itemNo);
						$('#sku').val(data.sku);
						$('#goodsName').val(data.goodsName);
						$('#goodsType').val(data.goodsType);
						$('#brand').val(data.brand);
						$('#specific').val(data.specific);
						$('#place').val(data.place);
						$('#property').val(data.property);
						$('#preBuyCost').val(data.preBuyCost);
						$('#price').val(data.price);
						$('#unit').val(data.unit);
						$('#isSale').val(data.isSale);
						$('#createTime').val(data.createTime);
						$('#updateTime').val(data.updateTime);

					}
				});
			}
		}

		function update() {
			$('#form').bootstrapValidator();
			var bootstrapValidator = $("#form").data('bootstrapValidator');
			bootstrapValidator.validate();
		    if(!bootstrapValidator.isValid()){
			   return;
		    }
		    
		    var formdata = $("#form").serializeObject();

			$.ajax({
				type : 'put',
				url : '/pGoodss',
				contentType: "application/json; charset=utf-8",  
				data : JSON.stringify(formdata),
				success : function(data) {
					layer.msg("修改成功", {shift: -1, time: 1000}, function(){
                        location.href = "pGoodsList.html";
                    });
				}
			});
		}
		
	</script>
</body>
</html>
